﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;

namespace EBA.Localization
{
    /// <summary>
    /// 空的本地化提供者
    /// </summary>
    public class EmptyLocalizationProvider : ILocalizationProvider
    {
        /// <summary>
        /// 翻译
        /// </summary>
        /// <param name="key">主键</param>
        /// <param name="culture">语言文化</param>
        /// <param name="defaultText">默认文本</param>
        /// <returns>翻译后的文本</returns>
        public string Translate(string key, CultureInfo culture, string defaultText = null)
        {
            return defaultText ?? key;
        }

        /// <summary>
        /// 更新翻译
        /// </summary>
        /// <param name="key">主键</param>
        /// <param name="culture">语言文化</param>
        /// <param name="text">翻译后的文本</param>
        public void Update(string key, CultureInfo culture, string text)
        {
           // throw new NotImplementedException();
        }


        /// <summary>
        /// 获取已经存在的语言文化列表
        /// </summary>
        /// <returns></returns>
        public IEnumerable<CultureInfo> GetCultures()
        {
           return CultureInfo.GetCultures(CultureTypes.AllCultures);
        }

        /// <summary>
        /// 获取已经存在的主键列表
        /// </summary>
        /// <returns></returns>
        public IQueryable<string> GetKeys(CultureInfo culture=null)
        {
            return Enumerable.Empty<string>().AsQueryable();
        }

        /// <summary>
        /// 获得指定文化所对应主键的文本值
        /// </summary>
        /// <param name="key"></param>
        /// <param name="culture"></param>
        /// <returns></returns>
        public string GetTextValue(string key, CultureInfo culture = null)
        {
            return key;
        }
    }
}
